import request from '@/utils/request'

//从配置中获取业务的地址
import {baseUrlConfig,baseUrl} from '@/config/config'
const businessBaseUrl = baseUrlConfig.businessBaseUrl
const processBaseUrl = baseUrlConfig.processBaseUrl
const fileReviewUrl = baseUrlConfig.fileReviewUrl

export interface ProcessType {
  content: {
    creator: {
      id: string,
      name: string,
      organId: string,
      organName: string
    },
    createTime: string
  },
  id: string,
  variables: {
    switch: string
  }
}

/**
 * 弃用
 * @param resourceKey
 */
export const getGetDict = (resourceKey: string) => {
  return request({
    url: processBaseUrl + '/common/tbResource',
    method: 'get',
    params: { resourceKey }
  })
}

export const deleteFile = (code: string) => {
  return request({
    url: businessBaseUrl + '/fast/deleteFile',
    method: 'get',
    params: { enclosureCode: code }
  })
}


export const deleteFiles = (code: string) => {
  return request({
    url: businessBaseUrl + '/file/del',
    method: 'delete',
    data:code
  })
}
export const uploadFiles = (data: any) => {
  return request({
    url: businessBaseUrl + '/file/put',
    method: 'put',
    data
  })
}
// 保存关联文件
export const saveFileRelate = (data: any) => {
  return request({
    url: businessBaseUrl + '/fast/saveFileInfo',
    method: 'post',
    data
  })
}

export const processComplete = (data: any) => {
  return request({
    url: processBaseUrl + '/process/complete',
    method: 'post',
    data
  })
}
export const downloadFiles = (data: any) => {
  return request({
    url: businessBaseUrl + '/fast/downloadFile?enclosureCode='+data,
    method: 'get',
    responseType: 'blob',
  })
}
//获取文件地址
export const onGetFileDownloadPath = (data: any) => {
  return request({
    url: businessBaseUrl + '/fast/downloadFile?enclosureCode='+data,
    method: 'get',
    responseType: 'blob',
  })
}
export const getFileDownloadPath = (data: any) => {
  return request({
    url: businessBaseUrl + '/fast/getFileDownloadPath?enclosureCode='+data,
    method: 'get',
  })
}
export const uploadKonwledgeFiles = (data: any) => {
  return request({
    url: businessBaseUrl + '/fast/uploadFile',
    method: 'post',
    data
  })
}
//文件转pdf
export const preViewPdf = (data: any) => {
  return request({
    url: fileReviewUrl + '/preview/documentConvert?enclosureCode='+data,
    method: 'get',
    responseType: 'blob',
  })
}
//ppt转pdf
export const preViewPPTToPdf = (data: any) => {
  return request({
    url: businessBaseUrl + '/preview/pptConvert?enclosureCode='+data,
    method: 'get',
    responseType: 'blob',
  })
}
